<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<c:if test="${empty user_id}">

<script type="text/javascript">
function renderButton() {
  google.friendconnect.renderSignInButton({ 'id': 'signin_button', 'style': 'long', 'text': 'Sign in' });
};
</script>
</c:if>

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('friendconnect', '0.8');
</script>

<script type="text/javascript">
google.friendconnect.container.setParentUrl('/' /* location of rpc_relay.html and canvas.html */);
google.friendconnect.container.initOpenSocialApi({
  site: '<c:out value="${friendConnectID}"/>',
  onload: function(securityToken) {
      if (!window.timesloaded) {
        window.timesloaded = 1;
        <c:if test="${not empty onFirstTimeLoad}">
          <c:out value="${onFirstTimeLoad}"/>
        </c:if>
      } else {
        window.timesloaded++;
      }
      if (window.timesloaded > 1) {
        window.top.location.href = '<c:out value="${redirectUrl}"/>';
      }
  }
});
</script>
